﻿using System.IO;
using System.Net;

namespace Golos.Http
{
    public class HttpResponse
    {
        public MemoryStream ResponseStream { get; private set; }
        public long ContentLength { get; private set; }
        public string ContentEncoding { get; private set; }
        public HttpStatusCode StatusCode { get; private set; }

        public HttpResponse(Stream responseStream, long contentLenght, string contentEncoding, HttpStatusCode statusCode)
        {
            if (contentLenght > 0)
            {
                byte[] data = new byte[contentLenght];
                responseStream.Read(data, 0, data.Length);
                ResponseStream = new MemoryStream(data);
                ResponseStream.Seek(0, SeekOrigin.Begin);
            }
            else
                ResponseStream = null;
            ContentLength = contentLenght;
            ContentEncoding = contentEncoding;
            StatusCode = statusCode;
        }
    }
}